package com.youshang520i;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;

/**
 * 终端执行命令：java -javaagent:/Users/youshang/software/apache/localRepository/org/aspectj/aspectjweaver/1.8.9/aspectjweaver-1.8.9.jar -jar spring-aspect-1.0-SNAPSHOT.jar
 *
 * @author youshang
 */
@Aspect
public class MyAspect {

    @Pointcut("call(* com.youshang520i.model.Account.withdraw())")
    public void pointcut() {

    }

    @Before("pointcut()")
//    @Before("execution(* com.youshang520i.model.Account.withdraw()))")
    public void before() {
        System.out.println(" before -> MyAspect");
//        return joinPoint.getThis();
    }

//    @Around("pointcut()")
//    public Object around(ProceedingJoinPoint joinPoint) {
//        System.out.println("around:" + joinPoint.getArgs());
//        try {
//            return joinPoint.proceed();
//        } catch (Throwable throwable) {
//            throwable.printStackTrace();
//        }
//        return null;
//    }
}
